<template>
	<view>
		<view class="goods-content goods">
			<view class="flex goods">
				<image :src="info.goodsImage" mode='widthFix' style="width: 2rem;"></image>
				<view style="width: 200px; margin: 0 10px;">
					<view class="goods-info">{{info.goodsName}}</view>
					<view class="goods-tag">
						<text>{{info.specName}}</text>
					</view>
				</view>
			</view>
		</view>

		<!--起租-->
		<view class="bill-items">
			<view class="bill-title">起租</view>
			<view v-for="(item,index) in info.stagesList" :key="index">
				<view v-if="[0,2].includes(item.status)">
					<view class="bill-info-list">
						<view class="bill-info-left">
							<view class="bill-left-top">
								<text>第{{item.currentLeaseTerm}}期:</text>
								<text style="padding-left: 10px;">¥{{item.periodicRent}}</text>
							</view>
							<view>
								账单日:{{item.payableDate}}
							</view>
						</view>
						<view class="bill-info-right">
							<view class="btn" @click="toPayFor(item)">去支付</view>
						</view>
					</view>
				</view>
				
				<view v-else>
					<view class="bill-info-list">
						<view class="bill-info-left">
							<view class="bill-left-top" style="color: #C0C4CC;">
								<text>第{{item.currentLeaseTerm}}期:</text>
								<text style="padding-left: 10px;">¥{{item.periodicRent}}</text>
							</view>
							<view style="color: #C0C4CC;margin-bottom: 8px;" v-if="item.status == 2">
								已逾{{item.overdueDays}}天 逾期金额{{item.overdueAmount}}
							</view>
							<view style="color: #C0C4CC;">
								账单日:{{item.payableDate}}
							</view>
						</view>
						<view class="bill-info-right" style="color: #C0C4CC;">已支付</view>
					</view>
				</view>
			</view>
		</view>
		
		
		<!--续租-->
		<view class="bill-items">
			<view class="bill-title">续租</view>
			<view v-for="(item,index) in info.endLeaseList" :key="index">
				<view v-if="[0,2].includes(item.status)">
					<view class="bill-info-list">
						<view class="bill-info-left">
							<view class="bill-left-top">
								<text>第{{item.currentLeaseTerm}}期:</text>
								<text style="padding-left: 10px;">¥{{item.periodicRent}}</text>
							</view>
							<view>
								账单日:{{item.payableDate}}
							</view>
						</view>
						<view class="bill-info-right">
							<view class="btn" @click="toPayFor(item)">去支付</view>
						</view>
					</view>
				</view>
				
				<view v-else>
					<view class="bill-info-list">
						<view class="bill-info-left">
							<view class="bill-left-top" style="color: #C0C4CC;">
								<text>第{{item.currentLeaseTerm}}期:</text>
								<text style="padding-left: 10px;">¥{{item.periodicRent}}</text>
							</view>
							<view style="color: #C0C4CC;margin-bottom: 8px;" v-if="item.status == 2">
								已逾{{item.overdueDays}}天 逾期金额{{item.overdueAmount}}
							</view>
							<view style="color: #C0C4CC;">
								账单日:{{item.payableDate}}
							</view>
						</view>
						<view class="bill-info-right" style="color: #C0C4CC;">已支付</view>
					</view>
				</view>
			</view>
		</view>
		
		<!--买断-->
		
		<view class="bill-items">
			<view class="bill-title">已买断</view>
			<view v-for="(item,index) in info.buyoutAmountList" :key="index">
				
				<view>
					<view class="bill-info-list">
						<view class="bill-info-left">
							<view class="bill-left-top" style="color: #C0C4CC;">
								<text>第{{item.currentLeaseTerm}}期:</text>
								<text style="padding-left: 10px;">¥899</text>
							</view>
							<view style="color: #C0C4CC;margin-bottom: 8px;" v-if="item.status == 2">
								已逾{{item.overdueDays}}天 逾期金额{{item.overdueAmount}}
							</view>
							<view style="color: #C0C4CC;">
								账单日:{{item.payableDate}}
							</view>
						</view>
						<view class="bill-info-right" style="color: #C0C4CC;">已支付</view>
					</view>
				</view>
			</view>
		</view>
		
		
		
	</view>
</template>

<script>
	import {
		getUserRentBillInfo
	} from '@/api/order.js';
	export default {
		data() {

			return {
				info: '',
				orderNo: '',
				status:''
			}
		},
		methods: {
			getData() {
				getUserRentBillInfo({
						orderNo: this.orderNo
					})

					.then(res => {
						this.info = res.data;
					})
			},
			//去支付
			toPayFor(row) {
				//跳转支付详情页
				uni.navigateTo({
					url: `/pages/goods/order_details/payInfo?orderNo=${this.orderNo}&isBuyout=${0}&renewal=${0}`
				});
			},
		},
		onLoad(options) {
			console.log(options,11111)
			this.orderNo = options.orderNo;
			this.status = options.status;
			this.getData();
		}
	}
</script>

<style scoped lang="scss">
	.bill-items {
		padding: 20px;

		.bill-title {
			font-size: 1.2em;
			font-weight: bold;
			color: #C0C4CC;
		}

		.bill-info-list {
			background-color: white;
			margin: 15px 0;
			padding: 15px;
			border-radius: 15px;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.bill-info-left {
				width: 70%;
				border-right: 1px dashed #E4E7ED;

				.bill-left-top {
					font-size: 1.1em;
					font-weight: bold;
					padding-bottom: 10px;
				}
			}

			.bill-info-right {
				width: 30%;
				display: flex;
				justify-content: center;

				.btn {
					width: 80%;
					background-color: rgba(237, 125, 61, 1);
					padding: 10px;
					color: white;
					border-radius: 20px;
					text-align: center;
				}
			}
		}
	}

	/* 商品信息 */
	.goods {
		margin: 10px;
		padding: 10px;
		background-color: #fff;
	}

	.goods img:first-child {
		width: 85px;
		height: 85px;
	}

	.goods-info {
		height: 35px;
		font-size: 1.1em;
		line-height: 19px;
		color: #262626;
		/* 溢出隐藏，省略号 */
		overflow: hidden;
		/* 文本超出给予省略号 */
		text-overflow: ellipsis;
		/* 溢出不换行 */
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-clamp: 2;
		-webkit-line-clamp: 2;
	}

	.goods-tag {
		margin: 10px 0;
	}

	.goods-tag span {
		font-size: 11px;
		color: #888;
		background-color: rgb(246, 247, 247);
	}

	.goods-price-icon {
		font-size: 9px;
		color: red;
	}

	.goods-price-num {
		font-size: 16px;
		color: red;
	}

	.line-through {
		text-decoration: line-through;
	}

	.gray {
		color: #888;
	}

	.goods-price p:last-child {
		margin-left: 10px;
	}
</style>